#include "utility.h"

std::string &Trim(std::string &s)
{
    if (s.empty())
        return s;
    s.erase(0, s.find_first_not_of(" "));
    s.erase(s.find_last_not_of(" ") + 1);
    return s;
}

std::vector<std::string> Split(std::string &s, const std::string &delimiter)
{
    std::vector<std::string> fields;
    size_t pos = 0;
    while ((pos = s.find(delimiter)) != std::string::npos)
    {
        fields.push_back( s.substr(0, pos));
        s.erase(0, pos + delimiter.length());
    }
    return fields;
}